package com.wkm.chainchain.pbft.node;

import com.wkm.chainchain.consensusutils.RSAUtils;
import lombok.Data;

/**
 * TODO 对Node节点进行解耦, 分为共识节点和客户端节点
 */
@Data
public class Node {
    private static Node node;

    /**
     * @return 当前节点的单例
     */
    public static Node getInstance() {
        if (node == null) {
            node = new Node();
            String[] keyPair = RSAUtils.generateKeyPair();
            if (keyPair != null) {
                node.publicKey = keyPair[0];
                node.privateKey = keyPair[1];
            }
        }
        return node;
    }

    public Node() {
    }

    private int index;

    private String ip;

    private int port;

    private String publicKey;

    private String privateKey;
}
